<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class LogoController extends  AdminController{
    public function logo(){
        $pic = DB::table('logo')->first();
        return view('logo.logo',['pic'=>$pic]);
    }

    public function uploadLogo(Request $request){//上传图片格式为297x77
        if($request->isMethod('post')){
            $data = $request->all();
            $imgAry = $data['url'];
            $pic = DB::table('logo')->first();
            $msg = '上传失败';
            if($pic){
                $res = DB::table('logo')->where('id',1)->update(['url' => $imgAry]) ?  $msg = '上传成功' :  $msg;
            }else{
                $res = DB::table('logo')->insert($imgAry) ?  $msg = '上传成功' :  $msg;
            }

            return response()->json(array('code'=>1,'msg'=>$res));
        }else{
            return response()->json(array('code'=>0,'msg'=>'请求方式错误'));
        }
    }
}
